﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml;
using System.Net;

namespace IGolovkine.AoA.Tcp.Channels.Http
{
    public class HttpChannelClientConfiguration : IConfiguration<IMessageChannel>
    {
        public HttpChannelClientConfiguration()
        {
            this.MinPollInterval = TimeSpan.FromSeconds(0.25);
            this.IdleModeTrigger = TimeSpan.FromSeconds(30);
            this.MaxPollInterval = TimeSpan.FromSeconds(30);
        }

        public IWebProxy Proxy { get; set; }
        public string ServerUrl { get; set; }

        public TimeSpan MinPollInterval { get; set; }
        public TimeSpan MaxPollInterval { get; set; }
        public TimeSpan IdleModeTrigger { get; set; }

        public IMessageChannel CreateInstance()
        {
            if (string.IsNullOrEmpty(ServerUrl) == true)
            {
                throw new ArgumentNullException("'ServerUrl' wasn't specified");
            }

            return new HttpChannelClient(this);
        }
    }
}
